package com.info.zhiduoduo.repository.mapper.weixin;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.weixin.WxNoticeDto;
import com.info.zhiduoduo.repository.entity.weixin.WxNotice;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author wang
 */
@Mapper
public interface WxNoticeMapper extends BaseMapper<WxNotice> {


    /**
     * 消息推送记录列表
     *
     * @return
     */
    @Select("select * from zdd_wx_notice ")
    List<WxNoticeDto> queryWxNotice();

    @Update("update zdd_wx_notice n set n.is_read = 1" +
            " where n.notice_type = 2 " +
            " and n.is_read = 0 " +
            " and n.user_id = #{compid} ")
    void updateAllRead(int compid);

    /**
     * 获取企业未读消息数量
     *
     * @return
     */
    @Select("select count(*) from zdd_wx_notice n " +
            " where n.notice_type = 2 " +
            " and n.is_read = 0" +
            " and n.user_id = #{compid} ")
    int queryCompWxNoticeUnRead(int compid);

}
